var util = require('../../utils/util.js');
var api = require('../../config/api.js');
var user = require('../../services/user.js');
var app = getApp();

Page({
    data: {
        info: {},

    },
    onPullDownRefresh: function () {
        wx.stopPullDownRefresh();
    },
    onLoad: function(options) {
        // 页面初始化 options为页面跳转所带来的参数
        this.getData(options.id)
    },
    onCall(){
        wx.makePhoneCall({
            phoneNumber: this.data.info.phone,
        })
    },
    onLocation(){
        const longitude = Number(this.data.info.lon)
		const latitude = Number(this.data.info.lat)
        wx.openLocation({
            latitude,
            longitude,
            scale: 18
        })
    },
    getData: function(id){
        let _this = this;
        wx.showLoading({
          title: '加载中...',
        })
        util.request(api.surroundings.getDetailMerchant+'/'+id,{},'post').then(res=>{
            _this.setData({
                info:res.result
            })
            wx.setNavigationBarTitle({
              title: res.result.merchantName,
            })
            wx.hideLoading()
        }).catch(err=>{
            console.log(err)
        })
    },
    onReady: function() {

    },
    onShow: function() {
    
        
    },
    onHide: function() {
        // 页面隐藏

    },
    onUnload: function() {
        // 页面关闭
    }
    
})
